package com.lsu.app.tool;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

//返回json格式类

/**
 * @author hjj
 * @date 2023/6/11 11:09
 */
@Data
public class R<T> {
    @ApiModelProperty(value="响应状态码")
    private Integer code;
    @ApiModelProperty(allowEmptyValue = true,value = "响应数据")
    private T data;
    @ApiModelProperty(allowEmptyValue = true,value = "错误信息")
    private String msg;

    public static <T> R<T> success(T object) {
        R<T> tr = new R<>();
        tr.code = 1;
        tr.data = object;
        return tr;
    }

    public static <T> R<T> err(String massage) {
        R<T> tr = new R<>();
        tr.code = 0;
        tr.msg = massage;
        return tr;
    }
}